<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/1/26
 * Time: 11:37
 */

namespace app\api\service;


class Goods
{
    static function list_($param, $injection = null)
    {
        $c = new \app\common\model\Goods();
        if ($injection instanceof \Closure) {
            call_user_func($injection, $c);
        }
        $r_data = $c->field("shop_sellers.*,shop_sellers.id as seller_id,shop_goods.*,shop_goods.id as goods_id")
            ->join("shop_sellers", "shop_sellers.id = shop_goods.seller_id")
            ->join("shop_community_seller_relation", "shop_goods.seller_id = shop_community_seller_relation.seller_id")
            ->where($param)
            ->paginate();
        return $r_data;
    }

    static function cate_($param)
    {
        $c = new \app\common\model\Goods();
        $c->field("shop_sellers.*,shop_sellers.id as seller_id,shop_goods.*,shop_goods.id as goods_id");
        $c->join("shop_sellers", "shop_sellers.id = shop_goods.seller_id");
        $c->join("shop_community_seller_relation", "shop_sellers.id = shop_community_seller_relation.seller_id");
        $r_data = $c->where($param)->paginate();
        return $r_data;
    }

    static function good($param)
    {
        $c = new \app\common\model\Goods();
        $c->field("shop_sellers.*,shop_sellers.id as seller_id,shop_goods.*,shop_goods.id as goods_id");
        $c->join("shop_sellers", "shop_sellers.id = shop_goods.seller_id");
        $c->join("shop_community_seller_relation", "shop_community_seller_relation.seller_id = shop_sellers.id");
//        $r_data = $c->where($param)->select(false);
        $r_data = $c->where($param)->find();
        return $r_data;
    }
}